class EventBus {
  constructor() {
    this.list = new Set();
  }
  on(key, value) {
    this.list.forEach(item => {
      if (item[0] === key) {
        item[1](value);
      }
    })
  }
  emit(key, fun) {
    return this.list.add([key, fun]);
  }
  remove(item) {
    this.list.delete(item);
  }
  removeAll(key) {
    this.list.forEach(item => {
      if (item[0] === key) {
        this.list.delete(item);
      }
    });
  }
}
export default new EventBus();